package com.atung.parking;

import com.atung.parking.entity.BusParkingOrders;
import com.atung.parking.enums.OrderState;
import com.atung.parking.mapper.BusParkingOrdersMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Component
@Log4j2
public class OrderTaskComponent {

    @Resource
    private BusParkingOrdersMapper busParkingOrdersMapper;
    @Scheduled(fixedRate = 60000)
    public void cancelOrder(){
        List<BusParkingOrders> busParkingOrders = busParkingOrdersMapper.select30MinAgo();
        busParkingOrders.stream().forEach(
                item->{
                    busParkingOrdersMapper.cancelOrderById(item.getId());
        });

    }
}
